package test;

public class Base {
    private String name = "Base";
    { System.out.println("A");}
    static { System.out.println("B"); }
    public Base () {
        printf();
        System.out.println("C");
    }
    public void printf() { System.out.println(name); }

    public static void main(String[] args) {
        Base b = new Sub();   // 输出顺序，为什么：
    }

    static class Sub extends Base {
        private static String name = "Sub";
        { System.out.println("A1"); name = "Sub1"; }
        static { System.out.println("B1"); name = "Sub2"; }
        public Sub () {
            printf();
            System.out.println("C1");
        }
        public void printf() { System.out.println(name); }
    }
}